/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projeto_piu;

import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.ButtonModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSeparator;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

/**
 *
 * @author LUANTAVARES
 */
//Parte 02
// Checkbox com 4 (quatro) opções
// Pelo menos 2 devem alterar algo na interface ou exibir mensagem de texto no prompt


public class Parte03 {

    private static class JButtonGroup {

        public JButtonGroup() {
        }
    }
    
    private Container container;
    private JLabel cb01;
    private JLabel cb02;
    private List<JLabel> listaLabels;
    private ButtonGroup grupo;
    
    public Parte03(JFrame janela){
        container = janela.getContentPane();
        this.listaLabels = new ArrayList<JLabel>();
        cb01 = new JLabel("");
        cb02 = new JLabel("");
        grupo =  new ButtonGroup();
    }
    
    public void executar(){
        this.addRadioButtons();
    }
    
    private void addRadioButtons(){
        final JRadioButton jRadioButton01 = new JRadioButton("RadioButton 01");
        final JRadioButton jRadioButton02 = new JRadioButton("RadioButton 02");
        JRadioButton jRadioButton03 = new JRadioButton("RadioButton 03");
        JRadioButton jRadioButton04 = new JRadioButton("RadioButton 04");
        
        ///
        ActionListener actionListener = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                if(jRadioButton01.isSelected()){
                   cb01.setText("RadioButton01 selecionado");
                } else {
                   cb01.setText(""); 
                }
                if(jRadioButton02.isSelected()){
                   cb02.setText("RadioButton02 selecionado");
                } else {
                   cb02.setText(""); 
                }
            }
        };
        jRadioButton01.addActionListener(actionListener);
        jRadioButton02.addActionListener(actionListener);

        
        ///
        
        JPanel pane3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
        JPanel pane4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
        
        
        container.setLayout(new GridLayout(5, 1));
        
        grupo.add(jRadioButton01);
        grupo.add(jRadioButton02);
        grupo.add(jRadioButton03);
        grupo.add(jRadioButton04);
        
        pane3.add(jRadioButton01);
        pane3.add(jRadioButton02);
        pane3.add(jRadioButton03);
        pane3.add(jRadioButton04);
        pane4.add(this.cb01);
        pane4.add(this.cb02);
        
        this.container.add(pane3);
        this.container.add(pane4);
    }
    
}
